package tech.eyao.hs60x.utils;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5Utils {
	
	
	public static String md5(Long userId) {
		MessageDigest md5 = null;
		try {
			md5 = MessageDigest.getInstance("MD5");
			md5.update(userId.toString().getBytes());
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		}
		int index;
		StringBuffer buf = new StringBuffer("");
		byte[] b = md5.digest();
		for (int offset = 0; offset < b.length; offset++) {
			index = b[offset];
			if (index < 0)
				index += 256;
			if (index < 16)
				buf.append("0");
			buf.append(Integer.toHexString(index));
		}
		return buf.toString();
	}
	
	public static void main(String[] args) {
		System.out.println(md5(100000l));
	}
}
